How Errors Are Handled
When an error occurs, AppleScript checks to see if the statement that caused the error is contained in a Try statement. A Try statement is a two-part compound statement that contains a series of AppleScript statements, followed by an error handler to be invoked if any of those statements causes an error. If the statement that caused the error is included in a Try statement, then AppleScript passes control to the error handler in the Try statement. After the error handler completes, control passes to the statement immediately following the end of the Try statement.If the error occurred within a subroutine and AppleScript does not find a Try statement in that subroutine, AppleScript checks to see if the statement that invoked the current subroutine is contained in a Try statement. If that statement is not contained in a Try statement, AppleScript continues up the call chain, going to the statement that invoked that subroutine, if any, and so on. If none of the calls in the call chain is contained in a Try statement, AppleScript stops execution of the script.